home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-valrea.ads < prev    next >
Text File  |  1996-01-30  |  4KB  |  66 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --                      S Y S T E M . V A L _ R E A L                       --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.6 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. package System.Val_Real is
  27. pragma Pure (Val_Real);
  28.  
  29.    function Scan_Real
  30.      (Str  : String;
  31.       Ptr  : access Positive'Base;
  32.       Max  : Positive'Base)
  33.       return Long_Long_Float;
  34.    --  This function scans the string starting at Str (Ptr.all) for a valid
  35.    --  real literal according to the syntax described in (RM 3.5(43)). The
  36.    --  substring scanned extends no further than Str (Max). There are three
  37.    --  cases for the return:
  38.    --
  39.    --  If a valid real is found after scanning past any initial spaces, then
  40.    --  Ptr.all is updated past the last character of the real (but trailing
  41.    --  spaces are not scanned out).
  42.    --
  43.    --  If no valid real is found, then Ptr.all points either to an initial
  44.    --  non-blank character, or to Max + 1 if the field is all spaces and the
  45.    --  exception Constraint_Error is raised.
  46.    --
  47.    --  If a syntactically valid real is scanned, but the value is out of
  48.    --  range, or, in the based case, the base value is out of range or there
  49.    --  is an out of range digit, then Ptr.all points past the real literal,
  50.    --  and Constraint_Error is raised.
  51.    --
  52.    --  Note: these rules correspond to the requirements for leaving the
  53.    --  pointer positioned in Text_Io.Get
  54.    --
  55.    --  Note: if Str is null, i.e. if Max is less than Ptr, then this is a
  56.    --  special case of an all-blank string, and Ptr is unchanged, and hence
  57.    --  is greater than Max as required in this case.
  58.  
  59.    function Value_Real (Str : String) return Long_Long_Float;
  60.    --  Used in computing X'Value (Str) where X is a floating-point type or an
  61.    --  ordinary fixed-point type. Str is the string argument of the attribute.
  62.    --  Constraint_Error is raised if the string is malformed, or if the value
  63.    --  out of range of Long_Long_Float.
  64.  
  65. end System.Val_Real;
  66.